<?php

class Zhishidi_Question_Block_Adminhtml_Question_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {

    public function __construct() {
        parent::__construct();

        $this->_objectId = 'id';

        $this->_blockGroup = 'zhishidi_question';
        $this->_controller = 'adminhtml_question';

        $this->_updateButton('save', 'label', Mage::helper('zhishidi_question')->__('Save Answer'));
        $this->_updateButton('delete', 'label', Mage::helper('zhishidi_question')->__('Delete Question'));

        $this->_formScripts[] = "
            function toggleEditor() {
                if (tinyMCE.getInstanceById('answer') == null) {
                    tinyMCE.execCommand('mceAddControl', false, 'answer');
                } else {
                    tinyMCE.execCommand('mceRemoveControl', false, 'answer');
                }
            }
            function saveAndContinueEdit(){
                editForm.submit($('edit_form').action+'back/edit/');
            }
        ";
    }

    public function getHeaderText() {
        if (Mage::registry('zhishidi_question_data') && Mage::registry('zhishidi_question_data')->getId()) {
            return Mage::helper('zhishidi_question')->__("Answer question '%s'", $this->htmlEscape(Mage::registry('zhishidi_question_data')->getId()));
        } 
    }

}